<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/form_advanced.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:16 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>报告大厅</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
    <link rel="shortcut icon" href="favicon.ico"> 
	<link href="<%=basePath%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="<%=basePath%>/hplus/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
	<style>
        .panel-body{
            margin-bottom: 16px;
        }

        .s_form{
            text-align: center;
            padding-top: 60px;
        }

        .s_box1 {
            margin-right: 10%;
            background: #fee087;
            padding: 20px;
            border-radius: 3px;
            float: left;
        }
        
        .s_box_chart{
            width: 300px;
            height: 256px;
            padding: 20px;
            border-radius: 3px;
            float: left;
        }

        .s_box1 p{
            font-size: 16px;
        }

        .s_box1 span{
            font-size: 12px;
            color: #8f721c;
            display: block;
        }
        
        .s_box{
            width:18%;
            margin-right:2%;
            background: #fee087;
            padding: 20px;
            border-radius: 3px;
            float: left;
        }

        .s_box p{
            font-size: 16px;
        }

        .s_box span{
            font-size: 12px;
            color: #8f721c;
            display: block;
        }

        .s_blue{
            background: #68cbf8;
            color: #fff;
        }

        .s_blue span{
            color: #fff;
        }
        
        .yellow_circle{
            width: 120px;
            height: 120px;
            background: #fee087;
            border-radius: 50%;
            padding-top: 30px;
            margin: 4px;            
        }

        .yellow_circle p{
            color: #333;
            text-align: center;
        }

        .yellow_circle p.people{
            color: #8f721c;
            font-size: 20px;
        }

        .yellow_circle_border{            
            width:130px;
            height:130px;
            border:1px solid #fee087;
            border-radius: 50%;
            margin-top:50px;
        }
        
        .s_col_sm_2{
            width: 160px;
            text-align: center;
        }

        .s_col_sm_2 label{
            padding: 0;
        }

        .col-sm-2{
            font-weight: normal;
        }
        
        .k_blue{
        	 border:1px solid #c9cff5;
        }
        
        .k_blue .yellow_circle{
        	background: #c9cff5;
        }
    </style>
    
    <script src="<%=basePath%>/hplus/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=basePath%>/hplus/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="<%=basePath%>/hplus/js/content.min.js?v=1.0.0"></script>
    <script src="<%=basePath%>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/cropper/cropper.min.js"></script>
    <script src="<%=basePath%>/hplus/js/demo/form-advanced-demo.min.js"></script>
    <script src="<%=basePath%>/hplus/js/plugins/footable/footable.all.min.js"></script>			
    <script src="<%=basePath%>/hplus/js/plugins/echarts/echarts.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <shiro:hasPermission name="markting_activity_report:overview">
                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">总览</a>
                </li>
                </shiro:hasPermission>
                <shiro:hasPermission name="markting_activity_report_hot">
                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">最热</a>
                </li>
                </shiro:hasPermission>
            </ul>
            <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                    <div class="panel-body">
                        <strong class="text-navy col-sm-5">活动营销</strong>
                        <div class="btn-group col-sm-2">
                            <button class="btn btn-white" id="activityDay" type="button" onclick="selectDateForThree(1);">日</button>
                            <button class="btn btn-white" id="activityWeek" type="button" onclick="selectDateForThree(2);">周</button>
                            <button class="btn btn-primary" id="activityMonth" type="button" onclick="selectDateForThree(3);">月</button>
                        </div>
			            <div class="col-sm-3" style="padding: 0;height: 40px;" id="data_5">
			                <div class="input-daterange input-group" id="datepicker">
			                    <input type="text" class="input-sm form-control" name="start" value="" id="starttimeTab">
			                    <span class="input-group-addon" style="height: 24px;">到</span>
			                    <input type="text" class="input-sm form-control" name="end"  value="" id="endtimeTab">				
			                </div>
			            </div>
			            <!-- 隐藏域 -->
			            <input type="text" class="input-sm form-control" name="start" value="" id="starttime" style="display:none;">
			            <input type="text" class="input-sm form-control" name="end"  value="" id="endtime" style="display:none;">	
                        <div class="col-sm-1">
                            <button class="btn btn-primary pull-right" onclick="screenClick();">筛选</button>
                        </div>
                        <div class="col-sm-1">
                        	<shiro:hasPermission name="markting_activity_report_overview:show_many"><a href="<%=path%>/activity/detailReport"><button class="btn btn-primary pull-right">查看更多</button></a></shiro:hasPermission>
                        </div>
                        <div class="tab-content">
	                        <div class="col-sm-2" style="margin-left:10px;">
	                        	<div class="s_col_sm_2">
					                <div class="yellow_circle_border">							
					                    <div class="yellow_circle">                
					                        <p>创建活动</p >
					                        <p class="people"><span id="activityPeo"></span></p >
					                        <p><span>次</span></p>
					                    </div>                    
					                </div>
				                </div>
				            </div>
	                        
	                        <div class="col-sm-2">
	                            <div class="s_col_sm_2">
					                <div class="yellow_circle_border k_blue">
					                    <div class="yellow_circle">                
					                        <p>总打开量</p >
					                        <p class="people"><span id="shareNum"></span>人</p >
					                    </div>                    
					                </div>
				                </div>
				            </div>
				            
	                        <div class="col-sm-4 " style="margin-left:-10px;">
	                        <!-- 渠道占比图形 -->
	                        <div class="col-sm-8">
	                      	  <div id="echarts-pie-chart" class="s_box_chart" style="margin:auto;"></div>
	                        </div>
	                        </div>
	                        
	                        <div class="col-sm-2">
	                        	<div class="s_col_sm_2">
					                <div class="yellow_circle_border">
					                    <div class="yellow_circle">                
					                        <p>商机转化</p >
					                        <p class="people"><span id="busZhNum"></span>人</p >
					                    </div>                    
					                </div>
				                </div>
				            </div>
	                        
	                        <div class="col-sm-2">
	                            <div class="s_col_sm_2">
					                <div class="yellow_circle_border k_blue">
					                    <div class="yellow_circle">                
					                        <p>转化率</p >
					                        <p class="people"><span id="zhl"></span></p >
					                    </div>                    
					                </div>			
				                </div>
				            </div>
			            </div>
                    </div>
                    <div class="panel-body">
                        <strong class="text-navy col-sm-5">短信营销</strong>
                        <div class="btn-group col-sm-2">
                            <button class="btn btn-primary" id="activityDay2" type="button" onclick="selectDateForThree2(1,1);">日</button>
                            <button class="btn btn-white" id="activityWeek2" type="button" onclick="selectDateForThree2(2,1);">月</button>
                            <button class="btn btn-white" id="activityMonth2" type="button" onclick="selectDateForThree2(3,1);">年</button>
                        </div>		
			            <div class="col-sm-3" style="padding: 0;height: 40px;" id="data_5">
			                <div class="input-daterange input-group" id="datepicker">
			                    <input type="text" class="input-sm form-control" name="start" value="" id="starttime2">
			                    <span class="input-group-addon" style="height: 24px;">到</span>
			                    <input type="text" class="input-sm form-control" name="end"  value="" id="endtime2">				
			                </div>
			            </div>     
                        <div class="col-sm-1">
                            <button class="btn btn-primary pull-right" onclick="dxyxSearch();" >筛选</button>
                        </div>
                        <br><br>
                        <div id="echarts-line-chart" style="height: 400px;"></div>
					    <script type="text/javascript">
					    			
				        var access_token=$.cookie('access_token');
				   	 	var cid=$.cookie('cid');
				   	 	var uid=$.cookie('uid');
				   	 	
				   	 	var realStartTime = "";
				   	 	var realEndTime = "";
				   	 	
				        $(function(){
				        	var myDate = new Date();
				        	//获取当前年
				        	var year=myDate.getFullYear();
				        	//获取当前月
				        	var month=myDate.getMonth()+1;
				        	var beforeMonth=myDate.getMonth();
				        	var beforeYear=year;
				        	//获取当前日
				        	var day=myDate.getDate(); 
				        	if(month>12){
				        		year=year+1;
				        		month=1;
				        	}
				        	if(beforeMonth==0){
				        		beforeMonth=12;
				        		beforeYear=beforeYear-1;
				        	}
				        	
				        	$("#endtime3").val(year+"-"+month+"-"+day);
				        	$("#endtime3").attr("value",year+"-"+month+"-"+day);
				        	$("#starttime3").attr("value",beforeYear+"-"+beforeMonth+"-"+day);
				        	$("#starttime3").val(beforeYear+"-"+beforeMonth+"-"+day);
				        	
				        	$("#endtime4").val(year+"-"+month+"-"+day);
				        	$("#endtime4").attr("value",year+"-"+month+"-"+day);
				        	$("#starttime4").attr("value",beforeYear+"-"+beforeMonth+"-"+day);
				        	$("#starttime4").val(beforeYear+"-"+beforeMonth+"-"+day);
				        	
				        	$("#starttime3").datepicker("setDate",beforeYear+"-"+beforeMonth+"-"+day);
				        	$("#endtime3").datepicker("setDate",year+"-"+month+"-"+day);  
				        	$("#starttime4").datepicker("setDate",beforeYear+"-"+beforeMonth+"-"+day);
				        	$("#endtime4").datepicker("setDate",year+"-"+month+"-"+day);  
				        	

				        	
				        	
				        	
				        	//初始化日期控件结束日期为当前时间，开始时间为一月前时间
				        	$("#starttime").val(getNowDate('fr')), //获取月初第一天
			  	            $("#endtime").val(getNowDate(0))
			  	            $("#starttimeTab").val(getNowDate('fr')), //获取月初第一天
			  	            $("#endtimeTab").val(getNowDate(0))
			  	            //短信营销
				        	$("#starttime2").val(getNowDate('fr')), //获取月初第一天
			  	            $("#endtime2").val(getNowDate(0))
			  	            
				        	//初始化活动次数
				        	initActivityNums();
				        	//初始化总分享量、渠道占比
				        	initActivityShareNums();
				        	//初始化渠道占比饼状图 
				        	initQdZbChart();
				        	//初始化商机转化饼状图
				        	initActiveDiv();
				        	//初始化转化率
				        	initZhbl();
				     
				        	
				        	//初始化报告大厅最热活动
				        	initHotAvtivity();
				        	//初始化报告大厅最热短信营销
				        	initHotSms();
				        	
				           	//初始化短信消耗折线图（更改为默认选中天）
				        	 //initQdPropChart();
				        	 if(sxClickTag == 2){
						        selectDateForThree2(1,1);
						     }
				        });
				        
				        //初始化活动次数
				        function initActivityNums(){
				        	  $.ajax({
				  	            type: "POST",
				  	            async: false,
				  	            url: "${pageContext.request.contextPath}/activity/ajaxActivityNums",
				  	            data: {
				  	            	"cid" : cid,
				  	            	"uid" : uid,
				  	            	"access_token" : access_token,
				  	            	"startTime":$("#starttime").val(),
				  	            	"endTime":$("#endtime").val()
				  	            	},
				  	            dataType: "json",
				  	      	    timeout: 1000,
				  	            success: function(data){
				  	            	if(data.status == 200){
				  	            		var activeData = data.data;
										//初始化活动次数
										$("#activityPeo").text(activeData);
				  	            	}
				  	            }	
				  			});	
				        }
				        
				        var qdZbArr = [];//渠道占比扇形图用到的数组
				        var qdZbNameArr = []; //渠道占比扇形图用到的数组名称
				        //初始化总分享量
				        function initActivityShareNums(){
				              qdZbArr = [];//清空占比扇形图用到的数组
					          qdZbNameArr = []; //清空渠道占比扇形图用到的数组名称
					          
				        	  $.ajax({
					  	            type: "POST",
					  	            async: false,
					  	            url: "${pageContext.request.contextPath}/activity/ajaxActivityTotalClickNum",
					  	            data: {
					  	            	"cid" : cid,
					  	            	"uid" : uid,
					  	            	"access_token" : access_token,
					  	            	"startTimeStr":$("#starttime").val()+" 00:00:00",					
					  	            	"endTimeStr":$("#endtime").val()+" 23:59:59"
					  	            	},
					  	            dataType: "json",
					  	      	    timeout: 1000,
					  	            success: function(data){
					  	            	if(data.status == 200){
					  	            		var activeData = data.data;
					  	          			//初始化总分享量					
											$("#shareNum").text(activeData.clickTotalNum);
												qdZbArr.push("QQ");
												qdZbArr.push("微博");
												qdZbArr.push("微信");
												qdZbArr.push("其他");
												
												var otherClick=activeData.clickTotalNum-activeData.qqClickNum-activeData.weiboClickNum-activeData.weixinClickNum;
												qdZbNameArr.push({value:activeData.qqClickNum, name:"QQ"});
												qdZbNameArr.push({value:activeData.weiboClickNum, name:"微博"});
												qdZbNameArr.push({value:activeData.weixinClickNum, name:"微信"});
												qdZbNameArr.push({value:otherClick, name:"其他"});
					  	            	}else{			
					  	            		qdZbNameArr.push({value:0, name:"暂无数据"});				
					  	            	}
					  	            }	
					  			});			
				        }
				        
				        var propChartDateArr = []; //唯一日期数组
				        var propChartDataArr = []; //唯一数据数组
				        var propDates  = "m"; //默认按月   月m ,日d ,年y
				        //初始化短信消耗折线图
				        function initQdPropChart(){
				        propChartDateArr = [];
				        propChartDataArr = [];
				     	var starttime2 = "";
			        	var endtime2 = "";
				        //0筛选 1选项卡	
				        if(sxClickTag == 0){
					        starttime2 = $("#starttime2").val()+" 00:00:00";
					        endtime2 = $("#endtime2").val()+" 23:59:59";
				        }else if(sxClickTag == 1){
				        	if(propDates == "d"){
				        		starttime2 = getNowDateNew('fr')+" 00:00:00";//获取月初第一天
				        		endtime2 = getNowDate(0)+" 23:59:59";
				        	}else if(propDates == "m"){
				        		starttime2 = getNowDateNew('month')+" 00:00:00";//获取年初第一天
				        		endtime2 = getNowDate(0)+" 23:59:59";
				        	}else if(propDates == "y"){
				        		starttime2 = getNowDateNew('year')+" 00:00:00";//获取年初第一天
				        		endtime2 = getNowDate(0)+" 23:59:59";
				        	}
				        }
				        var smsNum = "";
				        //按天、按月、按年获取短信消耗打开量和商机转化
						$.ajax({
			            type: "POST",
			            async: false,
			            url: "${pageContext.request.contextPath}/smsStatistics/ajaxGetQdPropChartData",
			            data: {
			            	"cid":cid,
			            	"uid" : uid,
			            	"access_token":access_token,
			            	"startIndex":0,
			            	"pageSize":10,
			            	"startTimeStr":starttime2,		
			            	"endTimeStr":endtime2,
			            	"dates":propDates
			            	},
			            dataType: "json",
			      	    timeout: 1000,
			            success: function(data){
			            	var activeData = data.data;
			            	var oneData = activeData[0]; //商机转化
			            	var chartData = [];
			            	for(var i=0;i<oneData.length;i++){
			            		propChartDateArr.push(oneData[i].dateStr);
			            		chartData.push(oneData[i].smsNum);
			            	}
			            	propChartDataArr.push({name:'商机转化',type:'line',data:chartData});
			            	var twoData = activeData[1]; //打开量			
			            	var chartData2 = [];
			            	for(var i=0;i<twoData.length;i++){
			            		chartData2.push(twoData[i].smsOpenNum);
			            	}
			            	propChartDataArr.push({name:'打开量',type:'line',data:chartData2});
			            	smsNum = activeData[2].total;
			            }						
					});	
						        	
					        // 基于准备好的dom，初始化echarts实例
					        var myChart = echarts.init(document.getElementById('echarts-line-chart'));
												
					        // 指定图表的配置项和数据
					        option = {
					            noDataLoadingOption :{
					                   	text: '暂无数据',				
					                   	effect:'bubble',
					                   	effectOption : {
					                   	effect: {
					                   	n: 0 //气泡个数为0 		
					                   	}
					                    }
					            },
							    title: {
							        text: '短信消耗:'+smsNum + '条'
							    },
							    tooltip: {
							        trigger: 'axis'
							    },
							    toolbox: {
							        show: true,
							        feature: {
							            dataZoom: {
							                yAxisIndex: 'none'
							            },
							            dataView: {readOnly: false},
							            magicType: {type: ['line', 'bar']},
							            restore: {},
							            saveAsImage: {}
							        }
							    },
							    legend: {
							        data:['打开量','商机转化']
							    },
							    color:['#54cdb4','#1bb495'],
							    grid: {
							        left: '3%',
							        right: '4%',
							        bottom: '3%',
							        containLabel: true
							    },
							    xAxis: {
							        type: 'category',
							        boundaryGap: false,
							        data: propChartDateArr
							    },
							    yAxis: {
							        type: 'value'
							    },
							    series:propChartDataArr

							};

					        // 使用刚指定的配置项和数据显示图表。
					        myChart.setOption(option);
				        }
				        
				        
				       	// 初始化渠道占比折线图
				       	function initQdZbChart(){
					        // 基于准备好的dom，初始化echarts实例
					        var myeChart = echarts.init(document.getElementById('echarts-pie-chart'));
	                        eoption = {
	                            noDataLoadingOption :{
	                                   	text: '暂无数据',				
	                                   	effect:'bubble',
	                                   	effectOption : {
	                                   	effect: {
	                                   	n: 0 //气泡个数为0 		
	                                   	}
	                                    }
	                            },
							    tooltip: {
							        trigger: 'item',
							        formatter: "{a} <br/>{b}: {c} ({d}%)"
							    },
							    legend: {
							        data:qdZbArr
							    },
							    color:['#04a8f4','#70ccf9','#b8e6fc','#f7f7f7'],
							    series: [
							        {
							            name:'渠道占比',
							            type:'pie',
							            radius: ['50%', '70%'],
							            avoidLabelOverlap: false,
							            label: {
							                normal: {
							                    show: false,
							                    position: 'center'
							                },
							                emphasis: {
							                    show: true,
							                    textStyle: {
							                        fontSize: '20',
							                        fontWeight: 'bold'
							                    }
							                }
							            },
							            labelLine: {
							                normal: {
							                    show: false
							                }
							            },
							            data:qdZbNameArr
							        }
							    ]
							};
	                     // 使用刚指定的配置项和数据显示图表。
					        myeChart.setOption(eoption);
				       	}
				       	
				       	
				   	 //初始化商机转化选项卡
				   	 function initActiveDiv(){
				   		$.ajax({
				               type: "POST",
				               async: false,
				               url: "${pageContext.request.contextPath}/activity/ajaxAllActivityConverNum",		
				               data: {
				               	"cid" : cid,
				               	"uid" : uid,
				               	"access_token" : access_token,		
			  	            	"startTime":$("#starttime").val(),
			  	            	"endTime":$("#endtime").val()
				               	},
				               dataType: "json",			
				         	    timeout: 1000,
				               success: function(data){
				               	if(data.status == 200){
				               		$("#busZhNum").text(data.data);					
				               	}
				               }	
				   		});			
				   	 }
				   	 
				   	 //初始化转化比率
				   	 function initZhbl(){
				   		 //转化率 = 提交表单量和分享量的比率		
				   		 var tjbdl = parseInt($("#busZhNum").text()); 
				   		 var fxl = parseInt($("#shareNum").text());
				   		 if(tjbdl != "" && tjbdl != null && tjbdl != 0 && fxl != "" && fxl != null && fxl != 0 ){
				   			 var zhlVal = (tjbdl / fxl * 100).toFixed(2);
				   			 $("#zhl").text(zhlVal + "%"); 
				   		 }else{
				   			 $("#zhl").text(0);
				   		 }
				   		
				   	 }
				   	 
				   	 //点击筛选后根据日期条件重新初始化图形
				   	 function screenClick(){
				   		 var sTime = $("#starttimeTab").val();
				   		 var eTime = $("#endtimeTab").val();
				   		if((parseInt(eTime.substring(0,4)) - parseInt(sTime.substring(0,4))) > 3){
				   			alert("时间区间不能超过3年");
				   			return;
				   		}
				   			$("#starttime").val(sTime)
				   			$("#endtime").val(eTime)
				        	//初始化活动次数
				        	initActivityNums();
				        	//初始化总分享量、渠道占比
				        	initActivityShareNums();
				        	//初始化渠道占比饼状图 
				        	initQdZbChart();
				        	//初始化商机转化饼状图
				        	initActiveDiv();
				        	//初始化转化率
				        	initZhbl();
				   	 }
				   	 
				   	 //点击筛选后根据日期条件重新初始化图形
				   	 function screenClickTab(){
				        	//初始化活动次数
				        	initActivityNums();
				        	//初始化总分享量、渠道占比
				        	initActivityShareNums();
				        	//初始化渠道占比饼状图 
				        	initQdZbChart();
				        	//初始化商机转化饼状图
				        	initActiveDiv();
				        	//初始化转化率
				        	initZhbl();
				   	 }
				   	 
					 //JS 获取当前时间
					 function getNowDate(day){	
						   var stime = new Date(); //开始时间
						   var stimeDay = "";		
						   var stimeMonth = "";
						   if(day == 30){
							   stimeDay = stime.getDate();
							   stimeMonth = stime.getMonth()+1 - 1; 
						   }else if(day == 'fr'){
							   stimeDay = 1;
							   stimeMonth = stime.getMonth()+1; 
						   }else if(day == 'week'){
							   var str = "";  
							   var week = stime.getDay();  
							   if (week == 0) {  
								   stimeDay = stime.getDate() - 6;  
							   } else if (week == 1) {  
								   stimeDay = stime.getDate();
							   } else if (week == 2) {  
								   stimeDay = stime.getDate() - 1;
							   } else if (week == 3) {  
								   stimeDay = stime.getDate() - 2;
							   } else if (week == 4) {  
								   stimeDay = stime.getDate() - 3;
							   } else if (week == 5) {  
								   stimeDay = stime.getDate() - 4;
							   } else if (week == 6) {  
								   stimeDay = stime.getDate() - 5;
							   }  
							   stimeMonth = stime.getMonth() + 1;
						   }else if(day == 'month'){
							   	stimeDay = 1;
							   	stimeMonth = 1;
						   }else if(day == 'year'){
							   stimeDay = 1;
							   stimeMonth = 1;
						   }else{
							   stimeDay = stime.getDate() - day;
							   stimeMonth = stime.getMonth() + 1;			
						   }
						   if(stimeMonth < 10){
						   stimeMonth = "0" + stimeMonth;}				
						   if(stimeDay < 10){
						   stimeDay = "0" + stimeDay;}
						   if(day == 'year'){
						   return stime.getFullYear() - 2 +"-"+(stimeMonth)+"-"+ stimeDay;
						   }else{
						   return stime.getFullYear()+"-"+(stimeMonth)+"-"+ stimeDay;   
						   }
					 }
					 
					 
					 //JS 获取当前时间
					 function getNowDateNew(day){	
						   var stime = new Date(); //开始时间
						   var stimeDay = "";		
						   var stimeMonth = "";
						   if(day == 30){
							   stimeDay = stime.getDate();
							   stimeMonth = stime.getMonth()+1 - 1; 
						   }else if(day == 'fr'){
							   stimeMonth = stime.getMonth()+1; 
							   stime.setMonth(stime.getMonth()-1);
							   stimeDay = stime.getDate();
						   }else if(day == 'month'){
							   	stimeMonth = stime.getMonth()+1;
							    for (var i = 0; i < 12; i++) {
							    	stime.setMonth(stime.getMonth()-1);//每次循环一次 月份值减1
							    }
							   	stimeDay = stime.getDate();
							
						   }else if(day == 'year'){
							    stimeMonth = stime.getMonth()+1;
							    stimeDay = stime.getDate();
						   }
						   if(stimeMonth < 10){
						   stimeMonth = "0" + stimeMonth;}				
						   if(stimeDay < 10){
						   stimeDay = "0" + stimeDay;}
						   if(day == 'year'){
						   return stime.getFullYear() - 2 +"-"+(stimeMonth)+"-"+ stimeDay;
						   }else{
						   return stime.getFullYear()+"-"+(stimeMonth)+"-"+ stimeDay;   
						   }
					 }
					 
					 var activityClickTime = 3;
					 //判断用户选择的是周 1、日 2、月 3
					 function selectDateForThree(date){
						 $("#activityDay").removeClass();
						 $("#activityWeek").removeClass();
						 $("#activityMonth").removeClass();
						 if(date == 1){
							 activityClickTime = 1;
		                     $("#activityDay").addClass("btn btn-primary");
			                 $("#activityWeek").addClass("btn btn-white");
			                 $("#activityMonth").addClass("btn btn-white");
			                 $("#starttime").val(getNowDate(0));		
			                 screenClickTab();//刷新图形
						 }else if(date == 2){
							 activityClickTime = 2;
			                 $("#activityDay").addClass("btn btn-white");
				             $("#activityWeek").addClass("btn btn-primary");
				             $("#activityMonth").addClass("btn btn-white");	
			                 $("#starttime").val(getNowDate('week'));
			                 screenClickTab();//刷新图形
						 }else if(date == 3){
							 activityClickTime = 3;
				             $("#activityDay").addClass("btn btn-white");
					         $("#activityWeek").addClass("btn btn-white");
					         $("#activityMonth").addClass("btn btn-primary");
					         $("#starttime").val(getNowDate('fr'));
					         screenClickTab();//刷新图形
						 }
					 }
					 
					 
					 var activityClickTime2 = 3;
					 //判断用户选择的是日 1、月 2、年 3
					 function selectDateForThree2(date,tag){
						 $("#activityDay2").removeClass();
						 $("#activityWeek2").removeClass();
						 $("#activityMonth2").removeClass();
						 sxClickTag = tag;
						 if(date == 1){
						 propDates = "d";
						 activityClickTime2 = 1;
	                     $("#activityDay2").addClass("btn btn-primary");
		                 $("#activityWeek2").addClass("btn btn-white");
		                 $("#activityMonth2").addClass("btn btn-white");
		                 //$("#starttime2").val(getNowDate(0));
		                 //screenClick();//刷新图形
		                 initQdPropChart();//刷新图形
						 }else if(date == 2){
						 propDates = "m";
						 activityClickTime2 = 2;
		                 $("#activityDay2").addClass("btn btn-white");
			             $("#activityWeek2").addClass("btn btn-primary");
			             $("#activityMonth2").addClass("btn btn-white");	
		                 //$("#starttime2").val(getNowDate(7));
		                 //screenClick();//刷新图形
		                 initQdPropChart();//刷新图形
						 }else if(date == 3){	
						 propDates = "y";
						 activityClickTime2 = 3;
			             $("#activityDay2").addClass("btn btn-white");
				         $("#activityWeek2").addClass("btn btn-white");
				         $("#activityMonth2").addClass("btn btn-primary");
				         //$("#starttime2").val(getNowDate(30));
				         initQdPropChart();//刷新图形
						 }
					 }
					 
					 //判断短信营销用户选中的是筛选还是选项卡0筛选、1选项卡、2是默认触发选项卡
					 var sxClickTag = 2;
					 
					//短信营销时间条件筛选
					 function dxyxSearch(){ 	
						 var st = $("#starttime2").val();
						 var et = $("#endtime2").val();
						 var dayNum = datedifference(st,et); //相隔天数
						 //如果结束时间 - 开始时间 > 3个月
						 if(dayNum >= 90 && dayNum <= 365){
							 selectDateForThree2(2,0); //切换为月
						 }else if(dayNum >= 365){
							 selectDateForThree2(3,0); //切换为年 				
						 }else{
							 selectDateForThree2(1,0); //切换为日	
						 }
					 }
					 //用户点击创建活动		
					 function createActive(){
						 window.location.href='${pageContext.request.contextPath}/api/bm/ui/createActivity1';
					 }
					 //用户点击创建短信
					 function createSms(){
						 window.location.href='${pageContext.request.contextPath}/api/bm/ui/choseSendObject?type=create';
					 }	
					 
					 
					 //两个时间相差天数 兼容firefox chrome
					 function datedifference(sDate1, sDate2) {    //sDate1和sDate2是2006-12-18格式  
					        var dateSpan,
					            tempDate,
					            iDays;
					        sDate1 = Date.parse(sDate1);
					        sDate2 = Date.parse(sDate2);
					        dateSpan = sDate2 - sDate1;
					        dateSpan = Math.abs(dateSpan);
					        iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
					        return iDays
					   };
					   
					  //初始化报告大厅最热短信营销
					  function initHotSms(){
					   		$.ajax({
					               type: "POST",
					               async: false,
					               url: "${pageContext.request.contextPath}/smsBatch/ajaxHotSmsBatch",		
					               data: {
					               	"cid" : cid,
					               	"uid" : uid,
					               	"access_token" : access_token,		
				  	            	"startTimeStr":$("#starttime4").val()+" 00:00:00",
				  	            	"endTimeStr":$("#endtime4").val()+" 23:59:59",
				  	            	"startIndex":0,
				  	            	"pageSize":5
					               	},
					               dataType: "json",			
					         	    timeout: 1000,
					               success: function(data){
					               	if(data.status == 200){
					               		var dataArr = data.data;	
					               		if(dataArr.length != 0){
						               		var html = "";
						               		for(var i=0;i<dataArr.length;i++){
							               		html += " <div class='s_box s_blue'>";
							               		html += " <p>"+dataArr[i].name+"</p>";
						                        html += " <span>打开次数："+dataArr[i].openNum+"</span>";
						                        html += " <span>行为转化："+dataArr[i].converNum+"</span>";
						                        html += " </div>";
						               		}
						               		$("#createSmsAlert").hide();
						               		$("#smsDivTop").html(html);  
					               		}else{
					               			$("#createSmsAlert").show();
					               		}
					               	}else{
					               		$("#smsDivTop").html("");  
					               		$("#createSmsAlert").show();
					               	}
					               }	
					   		});	
					  }
					  
					  //初始化报告大厅最热活动
					  function initHotAvtivity(){
						   		$.ajax({
						               type: "POST",
						               async: false,
						               url: "${pageContext.request.contextPath}/activity/ajaxHotActivityList",		
						               data: {
						               	"cid" : cid,
						               	"uid" : uid,
						               	"access_token" : access_token,		
					  	            	"startTimeStr":$("#starttime3").val()+" 00:00:00",
					  	            	"endTimeStr":$("#endtime3").val()+" 23:59:59",
					  	            	"startIndex":0,
					  	            	"pageSize":5
						               	},
						               dataType: "json",			
						         	    timeout: 1000,
						               success: function(data){
						               	if(data.status == 200){
						               		var dataArr = data.data;	
						               		if(dataArr.length != 0){		
							               		var html = "";
							               		for(var i=0;i<dataArr.length;i++){
								               		html += " <div class='s_box'>";
								               		html += " <p>"+dataArr[i].name+"</p>";
							                        html += " <span>打开次数："+dataArr[i].openNum+"</span>";
							                        html += " <span>行为转化："+dataArr[i].converNum+"</span>";
							                        html += " </div>";
							               		}			
							               		
							               		$("#createActiveAlert").hide();
							               		$("#activityDivTop").html(html);  
						               		}else{
						               			$("#createActiveAlert").show();
						               			$("#activityDivTop").html("");
						               		}
						               	}else{
						               		$("#activityDivTop").html("");
						               		$("#createActiveAlert").show();
						               	}
						               }	
						   		});	
						   		
					  }
					  
					  //活动营销筛选
					  function acticityDivSearch(){
						  initHotAvtivity();
					  }
					  
					  //短信营销筛选
					  function smsDivSearch(){
						  initHotSms();
					  }
					 
					  //查看全部活动跳转
					  function ckqb1(){		
						  window.location.href='${pageContext.request.contextPath}/view/ui/activityHome';
					  }
					  
					  //查看全部短信跳转
					  function ckqb2(){		
						  window.location.href='${pageContext.request.contextPath}/view/sms/smsStatistics';
					  }
										
					
					    </script>
					    <div style="height:20px;"></div>
                    </div>
                </div>
                <div id="tab-2" class="tab-pane">
                    <div class="panel-body">
                        <strong class="text-navy col-sm-7">活动营销</strong>
			            <div class="col-sm-3" style="padding: 0;height: 40px;" id="data_5">
			                <div class="input-daterange input-group" id="datepicker">
			                    <input type="text" class="input-sm form-control" name="start" value="2017-01-01" id="starttime3">
			                    <span class="input-group-addon" style="height: 24px;">到</span>
			                    <input type="text" class="input-sm form-control" name="end"  value="2017-12-31" id="endtime3">				
			                </div>
			            </div>                 
                        <div class="col-sm-1">
                            <button class="btn btn-primary pull-right" onclick="acticityDivSearch();">筛选</button>
                        </div>
                        <div class="col-sm-1">
                            <shiro:hasPermission name="activity_report_hot:show_all_activity">
                            <button class="btn btn-primary pull-right" onclick="ckqb1();">查看全部</button>
                            </shiro:hasPermission>
                        </div>
                        <div class="form-group s_form" style="display:none;" id="createActiveAlert" >   
                            <p>您还没有创建活动，请快创建活动吧</p>
                            <shiro:hasPermission name="activity_report_hot:create_activity">
                            <button class="btn btn-primary" onclick="createActive();" >创建活动</button>
                            </shiro:hasPermission>
                        </div>
                        
                        <div id="activityDivTop">

                        </div>
                    </div>
                    <div class="panel-body">
                        <strong class="text-navy col-sm-7">短信营销</strong>
			            <div class="col-sm-3" style="padding: 0;height: 40px;" id="data_5">
			                <div class="input-daterange input-group" id="datepicker">
			                    <input type="text" class="input-sm form-control" name="start" value="2017-01-01" id="starttime4">
			                    <span class="input-group-addon" style="height: 24px;">到</span>
			                    <input type="text" class="input-sm form-control" name="end"  value="2017-12-31" id="endtime4">				
			                </div>
			            </div>       
                        <div class="col-sm-1">
                            <button class="btn btn-primary pull-right" onclick="smsDivSearch();">筛选</button>
                        </div>
                    	<div class="col-sm-1">
                    	    <shiro:hasPermission name="activity_report_hot:show_all_sms_bus">
                            <button class="btn btn-primary pull-right" onclick="ckqb2();">查看全部</button>
                            </shiro:hasPermission>
                        </div>				
                       <!--  <div class="form-group s_form" style="display:none;" id="createSmsAlert">   
                            <p>您还没有创建短信，请快创建短信吧</p>						
                            <button class="btn btn-primary" onclick="createSms();">创建短信</button>
                        </div> -->
                        <div class="form-group s_form" style="display:none;" id="createSmsAlert">   
                            <p>无记录</p>						
                            
                        </div>
                        <div id="smsDivTop">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>